﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.ServiceProcess;

using Infrastructure.Utility;
using SMG.Monitor.Domain.Models;
using SMG.Monitor.Domain.Services;
using SMG.ServiceContract.System;
using Infrastructure.Core.IOC;
using Infrastructure.Core.Loging;
using Infrastructure.Dispatcher;


namespace SMG.Monitor.WinService
{
    partial class FirstMoveTask : ServiceBase
    {
        IDispatcher dispatcher;
        //日志服务
        ILogger logServer = LogService.GetInstance(LogType.Text);

        public FirstMoveTask()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            // TODO: 在此处添加代码以启动服务。
            try
            {
                dispatcher = new FirstTaskDispatcher();
                dispatcher.Start();
            }
            catch (Exception ex)
            {
                logServer.Info("FirstMoveTask.OnStart", ex.Message);
            }
        }

        protected override void OnStop()
        {
            // TODO: 在此处添加代码以执行停止服务所需的关闭操作。
            try
            {
                if (dispatcher != null)
                    dispatcher.Stop();
            }
            catch (Exception ex) {
                logServer.Info("FirstMoveTask.OnStop", ex.Message);
            }
        }
    }
}
